﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YmtAuth.Common.Utility;

namespace YmtUserAuth.DataImport
{
    public class UserData2
    {
        public string _id { get; set; }
        public Dictionary<int, Dictionary<string, object>> Value { get; set; }

        //IUserId,sLoginId, [sPassword], [sTradingPassword],[sLoginEmail] 
        public static IEnumerable<UserData2> Create(int userId,string loginId, string password, string tradingPassword,string email)
        {
            //生成用户value 值
            var value = new Dictionary<string, object> 
            {
                {"userId",userId},
                {"sLoginId",loginId},
                {"sTradingPassword",tradingPassword},
                {"sLoginEmail",email}
            };
            var userData = new Dictionary<int, Dictionary<string, object>> 
            {
                {userId,value}
            };
            yield return new UserData2
            {
                _id = CryptoUtil.Md5Encrypt(string.Format("{0}&{1}", loginId, password)),
                Value = userData
            };
            yield return new UserData2
            {
                _id = CryptoUtil.Md5Encrypt(string.Format("{0}&{1}", email, password)),
                Value = userData
            };
        }
    }
}
